<section class="content-wrapper">
	<div class="content-container container">
		<div class="breadcrum-container">
			<ul>
				<li><a href="#" title="Home">Home</a></li>
				<li>Man</li>
			</ul>
		</div>
		<div class="col-left">
			<div class="block man-block">
            	<div class="block-title"><?php echo $this->translate('brand'); ?></div>
            	<ul>
            		<?php foreach($this->brands as $brand): ?>
                        <li>
                            <a href="#" title="<?php echo $brand->brand; ?>">
                                <?php echo $brand->brand; ?>
                            </a>
                        </li>
                    <?php endforeach; ?>
            	</ul>
            </div>
            <!--<div class="block shop-by-block">
            	<div class="block-title">SHOP BY</div>
            	<ul>
            		<li>
                        
                    </li>
            	</ul>
            </div>
            <div class="block compare-block">
            	<div class="block-title">COMPARE PRODUCTS</div>
            	<ul>
            		<li>You have no items to compare</li>
            	</ul>
            </div>
            <div class="block community-block">
            	<div class="block-title">COMMUNITY POLL</div>
            	<ul>
            		<li class="question-row">WHAT IS YOUR FAVORITE COLOR</li>
            		<li><input type="radio"><a href="#" title="Green">Green</a></li>
            		<li><input type="radio"><a href="#" title="Red">Red</a></li>
            		<li><input type="radio"><a href="#" title="Black">Black</a></li>
            		<li><input type="radio"><a href="#" title="Magenta">Magenta</a></li>
            		<li class="vote-row"><button title="Vote">Vote</button></li>
            	</ul>
            </div>-->
            <div class="paypal-block">
            	<?php $bannerSidebar = $this->Banner('sidebar', 3); ?>
            	<?php foreach($bannerSidebar as $banner): ?>
                    <a href="<?php echo $banner->link; ?>" title="<?php echo $banner->banner; ?>">
                        <img src="<?php echo $banner->image; ?>" title="<?php echo $banner->banner; ?>" alt="<?php echo $banner->banner; ?>" />
                    </a>
                <?php endforeach; ?>
            </div>
		</div>
		<div class="col-main">
			<!--<div class="category-banner">
                <?php echo $this->render('banner/category.phtml'); ?>
            </div>-->
			<div class="new-product-block">
            <?php
                $items = $this->data->getItemsByPage($this->currentPage);
                $totalItem = count($items);
                $rows = ceil($totalItem / 3);
            ?>
            <?php for($row = 0; $row < $rows; $row ++): ?>
            <ul class="product-grid">
                <?php
                    $offset = $row * 3;
                    $max = $offset + 3;
                    
                    if($max >= $totalItem){
                        $max = $totalItem;
                    }
                ?>
                <?php for($i = $offset; $i < $max; $i ++): ?>
                <?php
                    $product = $items[$i];
                ?>
                    <li>
    					<div class="pro-img">
                            <img title="Freature Product" alt="Freature Product" src="<?php echo $product->image; ?>" />
                        </div>
    					<div class="pro-content">
                            <p><?php echo $product->name; ?></p>
                        </div>
    					<div class="pro-price">
                            <?php echo number_format($product->price, 0, null, "."); ?><?php echo $this->translate('currency'); ?>
                        </div>
    					<div class="pro-btn-block">
                            <input type="hidden" name="id" value="<?php echo $product->id; ?>" />
                            <?php if($product->quantity > $this->outOfStockLevel): ?>
                                <button type="button" class="add-cart left" id="addCart" title="Add to Cart">
                                    <?php echo $this->translate('add to cart') ?>
                                </button>
                            <?php else: ?>
    							<button class="add-cart left unavailability">
                                    <?php echo $this->translate('out of stock'); ?>
                                </button>
                            <?php endif; ?>
    						<a class="add-cart right" href="<?php echo $this->url(array('product_id' => $product->id, 'product_name' => $this->ConvertStringToURL($product->name)), 'product_detail', true); ?>" title="Quick View">
                                <?php echo $this->translate('quick view') ?>
                            </a>					
                        </div>
    					<div class="pro-link-block">
    						<div class="clearfix"></div>
    					</div>
    				</li>
                <?php endfor; ?>
            </ul>
            <?php endfor; ?>
			</div>
            <?php echo $this->paginationControl($this->data, 'Sliding' , 'pagination.phtml'); ?>
		</div>
		<div class="clearfix"></div>
		<div class="news-letter-container">
			<div class="free-shipping-block">
				<h1>ENJOY FREE SHIPPING</h1>
				<p>on all orders as our holiday gift for you!</p>
			</div>
			<div class="news-letter-block">
				<h2>SIGN UP FOR OUR NEWSLETTER</h2>
				<input type="text" value="Enter email address" title="" />
				<input type="submit" value="Submit" title="Submit" />
			</div>
		</div>	
	</div>
</section>
<script>
function loadCart(){
    $.ajax({
        type: "post",
        url: "<?php echo $this->url(array(), 'cart_load', true); ?>",
        success: function(result){
            $(".cart-block").empty();
            $(".cart-block").html(result);
        }
    });
}

$(document).ready(function(){
    $("button#addCart").click(function(){
        var id = $(this).parent().children("input[name='id']").val();
        var qty = 1;
        
        $.ajax({
            type: "post",
            url: "<?php echo $this->url(array(), 'cart_add', true); ?>",
            data: {'id': id, 'quantity': qty},
            success: function(result){
                alert("<?php echo $this->translate('add to cart success'); ?>");
                if(result.error == false){
                    loadCart();
                }else{
                    alert(result.message);
                }
            }
        });
    }); 
});
</script>